﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Entity;
using Utility;

namespace StudentAppointmentPlatform
{
    public partial class ServiceItem : System.Web.UI.UserControl
    {
        public AppointmentService Service { get; set; }
        private string loginType;

        protected void Page_Load(object sender, EventArgs e)
        {
            loginType = Session["LoginType"] as string;
            if (!string.IsNullOrWhiteSpace(loginType) && "Director" == loginType)
            {
                Modify.Visible = true;
            }
        }

        public void SetInfo()
        {
            ServiceName.Text = Service.ServiceName;
            DirectorName.Text = UserBO.GetUserNameById(Service.DirectorId) ?? string.Empty;

            if (false == (bool) Service.IsActive)
            {
                ServiceName.Text += "(已停用)";
                ServiceName.Attributes.CssStyle["text-decoration"] = "line-through";
            }
        }

        protected void Detail_OnClick(object sender, EventArgs e)
        {
            string id = Service.ServiceId.ToString();
            Alert.AlertOnPage2(Page, "为您跳转到详情页面...");
            Redirect.Js_Redirect2(Page, "/ServiceDetail.aspx?id=" + id);            
        }

        protected void Modify_OnClick(object sender, EventArgs e)
        {
            string id = Service.ServiceId.ToString();
            Alert.AlertOnPage2(Page, "为您跳转到修改页面...");
            Redirect.Js_Redirect2(Page, "/ServiceModify.aspx?id=" + id);        
        }
    }
}